package com.kh.reggie.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.kh.reggie.entity.DishFlavor;
import com.kh.reggie.entity.Orders;
import com.kh.reggie.mapper.OrdersMapper;
import com.kh.reggie.service.OrdersService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

@Service
public class OrdersServiceImpl extends ServiceImpl<OrdersMapper,Orders> implements OrdersService {
    @Autowired
    private OrdersService ordersService;

    @Override
    public Orders statusChange(Orders orders) {

        LambdaQueryWrapper<Orders> queryWrapper = new LambdaQueryWrapper();
        queryWrapper.eq(Orders::getId,orders.getId());
        List<Orders> ordersList = ordersService.list(queryWrapper);

//        添加过滤条件
       ordersList.stream().map(i->{
           i.setStatus(orders.getStatus());
           return i;
       }).collect(Collectors.toList());
       ordersService.updateBatchById(ordersList);

        return orders;
    }
}
